package com.eedi.framework.logger.controller.sys;
import com.eedi.framework.common.pojo.CommonResult;
import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.logger.controller.sys.vo.loginlog.SysLoginLogPageReq;
import com.eedi.framework.logger.controller.sys.vo.loginlog.SysLoginLogResp;
import com.eedi.framework.logger.dal.dataobject.SysLogLoginDO;
import com.eedi.framework.logger.service.SysLoginLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.eedi.framework.common.util.object.BeanUtils;
import javax.annotation.Resource;
import javax.validation.Valid;

import static com.eedi.framework.common.pojo.CommonResult.success;


@Tag(name = "系统界面 - 登录日志")
@RestController
@RequestMapping("/login-log")
@Validated
public class SysLoginLogController {

    @Resource
    private SysLoginLogService sysLoginLogService;

    @GetMapping("/page")
    @Operation(summary = "获得登录日志分页列表")
    @PreAuthorize("@sys.hasPermission('sys:login-log:query')")
    public CommonResult<PageResult<SysLoginLogResp>> getLoginLogPage(@Valid SysLoginLogPageReq pageReqVO) {
        PageResult<SysLogLoginDO> pageResult = sysLoginLogService.getLoginLogPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, SysLoginLogResp.class));
    }



}
